import cv2
import numpy as np
import matplotlib.pyplot as plt
img=cv2.imread('6.jpg')

src=cv2.cvtColor(img,cv2.COLOR_BGR2RGB)

height=src.shape[0]
width=src.shape[1]
numheight=height//8
numwidth=width//8
new_img=np.zeros((height,width,3),np.uint8)

for i in range(8):
    y=i*numheight
    for j in range(8):
        x=j*numwidth
        b = src[y, x][0]
        g = src[y, x][1]
        r = src[y, x][2]
        for n in range(numheight):
            for m in range(numwidth):
                new_img[y+n,x+m][0]=np.uint8(b)
                new_img[y + n, x + m][1] = np.uint8(g)
                new_img[y + n, x + m][2] = np.uint8(r)

titles=['src','Sampling']
images=[src,new_img]

plt.figure(figsize=(10,4))
for i in range(2):
    plt.subplot(1,2,i+1)
    plt.imshow(images[i])
    plt.title(titles[i])
    plt.axis('off')
plt.show()